<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
 <body>
	<head>
		<meta charset="UTF-8">
		<title>myRead</title>
		 <link href="../assets/css/bootstrap.css" rel="stylesheet" />
	     <!-- FontAwesome Styles-->
	    <link href="../assets/css/font-awesome.css" rel="stylesheet" />
	    <link href="../css/pulic.css" rel="stylesheet"/>
	     <!-- Google Fonts-->
	   <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
	     <!-- TABLE STYLES-->
	    <link href="../assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
        <script src="../js/layui/layui.js"></script>
        <script src="../js/jquery-3.2.1/jquery-3.2.1.js"></script>
		 <style media="screen">
        	.ECalendar{width:120px;height:30px;}
    	</style>
	</head>
	<body>
			<div class="panel-heading">
               <h1 class="page-header">
                  	我的已阅
              </h1>
            </div>
                    <div class="row" style="margin-left: 2%;">
						<form class="form-inline" >
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="read_choose_reimbursementTypeName" placeholder="请输入标题">
                            </div>
                            
                            <div class="form-group" style="margin-left: 1%;">
                                <input type="date" class="form-control" id="read_choose_startTime" placeholder="请输入日期"> -
                             	<input type="date" class="form-control" id="read_choose_endTime" placeholder="请输入日期">
                            </div>
                            
                            <button type="button" class="btn btn-info" id="read_choose">搜索</button>
                        </form>
					</div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>已阅标题</th>
                                            <th>接收者账号</th>
                                            <th>补单时间</th>
                                            <th>发送者账号</th>
                                        </tr>
                                    </thead>
                                    <tbody id="read_menu">
                                    	<c:forEach items="${readList}" var="read">
                                        <tr class="popup">
                                            <td style="display: none" class="reimbursementId">${read.reimbursementId }</td>
                                            <td class="reimbursementTypeName">${read.reimbursementTypeName }-${read.userName }</td>
                                            <td>${read.r_userId }</td>
                                            <td>${read.supplementTime }</td>
                                            <td>${read.w_userId }</td>
                                        </tr>
                                        </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                   
                    <!--分页功能-->
                         <div class="row" style="margin-left: 25%;margin-bottom:1%">
                   	<div class="col-sm-6">
                   		<div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
                   			<ul class="pagination">
                   				<li class="paginate_button previous" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_previous">
                   					<a href="myRead.do?pageNow=1">首页</a>
                   				</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
								  <c:choose> 
								   <c:when test="${page.pageNow - 1 > 0}"> 
								    <a href="myRead.do?pageNow=${page.pageNow - 1}" rel="external nofollow" >上一页</a> 
								   </c:when> 
								   <c:when test="${page.pageNow - 1 <= 0}"> 
								    <a href="myRead.do?pageNow=1" rel="external nofollow" rel="external nofollow" >上一页</a> 
								   </c:when> 
								  </c:choose> 
								</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
									<a>第 ${page.pageNow} 页</a>
								</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
									<c:choose> 
									<c:when test="${page.totalPageCount==0}"> 
										<a href="myRead.do?pageNow=${page.pageNow}" rel="external nofollow" rel="external nofollow" >下一页</a> 
									</c:when> 
									<c:when test="${page.pageNow + 1 < page.totalPageCount}"> 
									    <a href="myRead.do?pageNow=${page.pageNow + 1}" rel="external nofollow" >下一页</a> 
									</c:when> 
									<c:when test="${page.pageNow + 1 >= page.totalPageCount}"> 
									    <a href="myRead.do?pageNow=${page.totalPageCount}" rel="external nofollow" rel="external nofollow" >下一页</a> 
									</c:when> 
									</c:choose> 
								</li>
								<li class="paginate_button next" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_next">
								  <c:choose> 
								   <c:when test="${page.totalPageCount==0}"> 
								    <a href="myRead.do?pageNow=${page.pageNow}" rel="external nofollow" rel="external nofollow" >尾页</a> 
								   </c:when> 
								   <c:otherwise> 
								    <a href="myRead.do?pageNow=${page.totalPageCount}" rel="external nofollow" rel="external nofollow" >尾页</a> 
								   </c:otherwise> 
								  </c:choose> 
								</li>
                   			</ul>
                   		</div>
                   	</div>
                   </div>
	</body>

 <script src="../assets/js/jquery-1.10.2.js"></script>
      <!-- Bootstrap Js -->
    <script src="../assets/js/bootstrap.min.js"></script>
    <!-- Metis Menu Js -->
    <script src="../assets/js/jquery.metisMenu.js"></script>
     <!-- DATA TABLE SCRIPTS -->
    <script src="../assets/js/dataTables/jquery.dataTables.js"></script>
    <script src="../assets/js/dataTables/dataTables.bootstrap.js"></script>
        <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });

            layui.use('layer', function(){
                var layer = layui.layer;
            });
            $('.popup').on('click', function(){
            	var reimbursementId = $(this).closest("tr").find(".reimbursementId").text();//报销id
            	var reimbursementTypeName = $(this).closest("tr").find(".reimbursementTypeName").text(); //报销类型名
            	console.log("--"+reimbursementId);
            	console.log("--"+reimbursementTypeName);
                layer.open({
                    type: 2,
                    title: '详细信息',
                    maxmin: true,
                    shadeClose: false, //点击遮罩关闭层
                    area : ['80%' , '80%'],
                    content: ['${pageContext.request.contextPath}/read/someSingles.do?reimbursementId='+reimbursementId+'&reimbursementTypeName='+reimbursementTypeName+'','yes']
                });
            });
            
            $("#read_choose").click(function() {
        		var userName = $("#read_choose_reimbursementTypeName").val();//填写用户名
        		var startTime = $("#read_choose_startTime").val();//填写开始时间
        		var endTime = $("#read_choose_endTime").val();//填写结束时间
        		console.log(userName);
            	console.log(startTime);
            	console.log(endTime);
        		var workInfo = {
        				"userName":userName,
        				"startTime":startTime,
        				"endTime":endTime
        		};
        		
        	  	if(userName == '' && startTime == '' && endTime == ''){
            		layer.msg("请输入查询条件！");
            	}else{
            	
            	var chooseJson = {
            		"userName":userName,
            		"startTime":startTime,
            		"endTime":endTime
            	}
        		    	$.ajax({
        					type:"post",
        					url:"${pageContext.request.contextPath}/read/chooseRead.do",
        					dataType:"json",
        					data:chooseJson,
        					success:function(data){
        						console.log(data);
        						if(data == ''){
        							layer.msg("查无此数据！");
        						}else{
        							//layer.msg("!!！");
        							$("#read_menu").children().remove();
        							var str = '';
        							$.each(data,function(key,val){
        								str += '<tr class="popup">'
                                       		+' <td style="display: none" class="reimbursementId">'+val.reimbursementId+'</td>'
                                       		+' <td class="reimbursementTypeName">'+val.reimbursementTypeName+'-'+val.userName+'</td>'
                                       		+' <td>'+val.r_userId+'</td>'
                                        	+'<td>'+getMyDate(val.supplementTime)+'</td>'
                                        	+'<td>'+val.w_userId +'</td>'
        					               	+'</tr>'
        							});
        							$("#read_menu").append(str);
        						}
        						
        					},
        					error:function(){
        						console.log("我错了");
        					}
        				});
            	}
        });

            //str为传入的字符串为毫秒值
            function getMyDate(str){  
                  var oDate = new Date(str),  
                  oYear = oDate.getFullYear(),  
                  oMonth = oDate.getMonth()+1,  
                  oDay = oDate.getDate(),  
                  oHour = oDate.getHours(),  
                  oMin = oDate.getMinutes(),  
                  oSen = oDate.getSeconds(),  
                  oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);
                  //最后拼接时间为 1999-10-02 11:23:01样式 
                  return oTime;  
              };  
            //补0操作  
              function getzf(num){  
                  if(parseInt(num) < 10){  
                      num = '0'+num;  
                  }  
                  return num;  
              }  
            
    </script>
         <!-- Custom Js -->
    <script src="../assets/js/custom-scripts.js"></script>
    <script src="../js/Ecalendar.jquery.min.js"></script>

</html>